package com.pescamillam.kiosco.main;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import com.pescamillam.kiosco.util.Constants;
import com.pescamillam.kiosco.windows.Keyboard;

public class Main{
	JFrame main;
	public static boolean test = true;
	
	public Main() {
	  
		try {
			File properties = new File("properties.properties");
			if (!properties.exists()) {
				String codigoExtra = JOptionPane.showInputDialog("Inserte codigo final");
				FileWriter fw = new FileWriter(properties);
				fw.write(codigoExtra);
				fw.close();
				Constants.machineCode = codigoExtra;
			} else {
				FileReader fr = new FileReader(properties);
				BufferedReader br = new BufferedReader(fr);
				String codigoExtra = br.readLine();
				br.close();
				Constants.machineCode = codigoExtra;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		main = Keyboard.getInstance();
		main.setExtendedState(JFrame.MAXIMIZED_BOTH);
		main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		main.setUndecorated(true);
		main.setVisible(true);
		main.setFocusable(true);
		main.setFocusTraversalKeysEnabled(false);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}
